package cj.web.sc.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.sc.domain.SCSeller;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SCSellerDAO{
    @SQL("select * from SCSeller where id=:1")
    SCSeller queryById(int id);
    
    @SQL("select id,name from SCSeller where deleteFlag=1")
    List<Map> queryAll();
    
    @SQL("select * from SCSeller where deleteFlag=1 and userInfoId=:1")
    SCSeller queryByUserInfoId(int id);
    
    @SQL("INSERT INTO SCSeller (userInfoId,logo,name,phone,address,descs,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.userInfoId,:t.logo,:t.name,:t.phone,:t.address,:t.descs,:t.deleteFlag,NOW(),:t.createUser,NOW(),:t.updateUser)")
    void create(@SQLParam("t") SCSeller sCSeller);
	
	@SQL("UPDATE SCSeller SET userInfoId=:t.userInfoId,logo=:t.logo,name=:t.name,phone=:t.phone,address=:t.address,descs=:t.descs,updateAt=NOW(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") SCSeller sCSeller);
    
    @SQL("UPDATE SCSeller SET deleteFlag=0,updateAt=NOW(),updateUser=:t.updateUser  WHERE id=:t.id")
    void deleteById(@SQLParam("t") SCSeller sCSeller);

    @SQL("select * from SCSeller where deleteFlag=1 #if(:t.name!=''){ and name like '%##(:t.name)%' } #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } #if(:2!=-1){ and userInfoId= :2} ORDER BY sort DESC LIMIT :t.start,:t.length")
	List<SCSeller> queryByUserId(@SQLParam("t")SCSeller sCSeller, int userId);
    
    @SQL("select count(1) from SCSeller where deleteFlag=1 #if(:t.name!=''){ and name like '%##(:t.name)%' } #if(:t.phone!=''){ and phone like '%##(:t.phone)%' } #if(:2!=-1){ and userInfoId= :2}")
	int sizeByUserId(@SQLParam("t")SCSeller sCSeller, int userId);
}